######
### Information to replicate the analysis for "The Morning After: Cabinet Instability and the Purging of Ministers after Failed Coup Attempts in Autocracies"
### The Journal of Politics
######

# Intro ---

We are using Stata to conduct the country-level analysis, while we are using R to conduct the individual-level analysis. Below we briefly go through the relevant information to run the scripts.

# Replicating the country-level analysis in Stata ---

The analysis is found in the file "morning_after_dofile_countrylevel.do", while the data is found in "morning_after_dataset_countrylevel.dta".
We provide the full code to replicate Figure 2. However, for the appendices we only provide the code to replicate the results.

The Stata dofile replicates the following figures and appendices:

 - Figure 2
 - Appendix A
 - Appendix B
 - Appendix C
 - Appendix D
 - Appendix E
 - Appendix F
 - Appendix G
 - Appendix H
 - Appendix I
 - Appendix J

# Replicating the individual-level analysis in R ---

The analysis is found in the file "morning_after_dofile_individuallevel.r", while the data is found in "morning_after_dataset_individuallevel.csv".

You will need to download the R-packages "tidyverse", "texreg", "haven", and "lfe" to run the analyses. This should be done automatically when running the script using the "pacman"-package and the p_load command.

The following things may be worth noting:
- Figure 1 is based on the country-level data found in the file "morning_after_dataset_countrylevel.dta".
- The script prints all outputs to the subfolder "output".
- The script does not follow the alphabetical order from the appendices in the paper, since the different outputs runs on different subsets of the data. Instead, it runs all analyses using the first subset of the dataset, then the second, and so forth.

The R script replicates the following figures and appendices:

 - Figure 1
 - Figure 3
 - Figure 4
 - Figure 5
 - Appendix K
 - Appendix L
 - Appendix M
 - Appendix N
 - Appendix O
 - Appendix P
 - Appendix Q
 - Appendix R

